package com.atguigu.java;

/**
 * @author yihu
 * @email 1057202547@qq.com
 * @create 2020-11-2020-11-20-22:41
 * @des
 *
 * 例子：创建三个窗口卖票，总票数为100张.使用继承Thread类的方式
 *  * 存在线程的安全问题，待解决。
 *
 *
 */
public class WindowTest {
    public static void main(String[] args) {
        Window w1 = new Window("窗口1");
        Window w2 = new Window("窗口2");
        Window w3 = new Window("窗口3");

        w1.start();
        w2.start();
        w3.start();
    }
}

class  Window extends  Thread {

    private static int ticker = 100;

    @Override
    public void run() {
        while (true){
            if(ticker > 0){
                System.out.println(getName()+ ": 卖票,票号为：" + ticker);
                ticker--;
            }else {
                break;
            }
        }
    }
    public  Window(String name){
        super(name);
    }

}

